package com.baway.biliclitent.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.baway.biliclitent.R;
import com.baway.biliclitent.model.DetailsBean;

import java.util.List;

/**
 * 1.类的用途：目录的适配器
 * 2.渠刚
 * 3.@date
 * 4.用途:
 */
public class MySeleRecyAdapter extends RecyclerView.Adapter<MySeleRecyAdapter.MyViewHolder>{
    private Context context;
    List<DetailsBean.ResultBean.EpisodesBean> dataList;
    public MySeleRecyAdapter(Context context) {
        this.context = context;
    }
    public void setData(List<DetailsBean.ResultBean.EpisodesBean> dataList){
        this.dataList = dataList;
        this.notifyDataSetChanged();
    }
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_sele_layout, parent, false);
        MyViewHolder myViewHolder = new MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
            holder.indexTv.setText("第"+(position+1)+"话");
            holder.indetailsTv.setText(dataList.get(position).getIndex_title());

    }

    @Override
    public int getItemCount() {
        return dataList==null?0:dataList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        private final TextView indexTv;
        private final TextView indetailsTv;

        public MyViewHolder(View itemView) {
            super(itemView);
            indexTv = (TextView) itemView.findViewById(R.id.indexTv);
            indetailsTv = (TextView) itemView.findViewById(R.id.index_detailsTv);
        }
    }
}
